--[[
 -- *名称:cardshape
 -- *描述:花色枚举类
 -- *版权:Copyright © 2016-2018 深圳市三只小熊科技有限公司 版权所有
 -- *作者:Administrator
 -- *创建日期:2017-11-07
 -- *修改日期:2017-11-07
 -- @return [description]
 ]]

local CardShape = pokercore.class();
local t = {
--方块
["DIAMOND"] =  {0,"D"},
--梅花
["CLUB"] = {1,"C"},
--红桃
["HEART"] = {2,"H"},
--黑桃
["SPADE"] = {3,"S"},
--小鬼
["BLACK_JOKER"] = {4,"BJ"},
--大鬼
["RED_JOKER"] = {5,"RJ"},
}

--设置元表
local mt = {};

---
 -- [__eq 相等]
 -- @DateTime 2017-11-07
 -- @param    c1 [description]
 -- @param    c2 [description]
 -- @return    [description]
 --
mt.__eq = function (c1, c2) 
    if c1 and c2  and (c1.shape == c2.shape) then
        return true ;
    end
    return  false ;
end

---
 -- [ctor 构造]
 -- @DateTime 2017-11-07
 -- @param    shape [description]
 -- @param    simple [description]
 -- @return    [description]
 --
function CardShape:ctor(shape,simpleName)
   self.shape = shape ;
   self.simpleName = simpleName ;
   local meta = getmetatable(self) or {};
   table.merge(meta,mt)
   setmetatable(self,meta)
end

---
 -- [valueOf 获取枚举类型]
 -- @DateTime 2017-11-07
 -- @param    tShape [description]
 -- @return    [description]
 --
function CardShape.valueOf(tShape) 
   for k,v in  pairs(t) do
      if v[1] == tShape then
          return CardShape[k] ;
      end
   end

   --print("can not find cardShape!\n",debug.traceback());
   return nil ;
end

function CardShape:getSimpleName()
   return self.simpleName ;
end

function CardShape:getShape()
   return self.shape ;
end





local addAllShape = function()
 
    for k,v in pairs(t) do
      CardShape[k] = pokercore.new(CardShape,v[1],v[2]) ;
    end
end

addAllShape();

return CardShape ;